package icu.javacg.storage.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import icu.javacg.storage.pojo.Area;
import icu.javacg.storage.pojo.vo.ReturnResult;
import icu.javacg.storage.service.AreaService;
import icu.javacg.storage.mapper.AreaMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author sky
* @description 针对表【area(区域表)】的数据库操作Service实现
* @createDate 2023-04-25 08:42:29
*/
@Service
public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area>
    implements AreaService{
    @Autowired
    private AreaMapper areaMapper;
//
    @Override
    public List<Area> selectAll() {
        List<Area> areas = areaMapper.selectList(null);
        return areas;
    }

    @Override
    public ReturnResult<Area> addArea(Area area) {
         Boolean insert = areaMapper.insert(area)>0;
         if (insert){
             return new ReturnResult<>(880,"添加成功");
         }
            return new ReturnResult<>(830,"添加失败");
    }

    @Override
    public Page<Area> pageList(int a, int b) {
        Page<Area> page = new Page<>(a, b);
        Page<Area> areaPage = areaMapper.selectPage(page, null);
        return areaPage;
    }
}




